#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
//
//int main()
//{
//	char* ptr = new char[100];
//	delete[]ptr;
//	return 0;
//}#include <iostream>
using namespace std;

int main() {
    long long m = 1;
    //cin >> m;
    for (long long i = 0; i < m; i++)
    {
        long long n = 0;
        cin >> n;
        if (n == 1)
        {
            cout << 1 << endl;
        }
        if (n == 2)
        {
            cout << 2 << endl;
        }
        long long j = 2;
        long long a = 1, b = 2, c = 0;
        while (j != n)
        {
            c = 2 * b + a;
            a = b;
            b = c;
            j++;
        }

        printf("%lld\n", (c % 32767));
    }
    return 0;
}